package com.xtinno.service;

import com.xtinno.service.impl.CauseTraitWorkFlowImpl;
import com.xtinno.service.impl.WorkFlowServiceImpl;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
@Scope("prototype")
public class WorkFlowFactory {
    @Autowired
    @Qualifier("WorkFlowServiceImpl")
    private WorkFowService workFlowService;
    @Autowired
    @Qualifier("CauseTraitWorkFlowImpl")
    private WorkFowService causeTraitWorkFlowImpl;
    // 构建映射关系
    private Map<String, WorkFowService> workFlowMap = new HashMap<>();

    @PostConstruct
    public void init() {
        workFlowMap.put("causecharacteristicmatch", causeTraitWorkFlowImpl);
    }

    public WorkFowService getWorkFlowMap(String workFlwoId) {
        WorkFowService service = workFlowMap.get(workFlwoId);
        if (service == null) {
            return workFlowService;
        }
        return service;
    }
}
